Procedure for finding cues used for breeding by plovers

  1. Clean and process nest data file for each population.
  2. Remove multiple clutches for populations with bird references files (Cheetham and Hungary).
  3. Calculate number of nests per week for all study years.
  4. Calculate moving averages for temperature for pre-laying periods consisting of varying number of weeks. They are used in the code as follows :
    1. temp.1.week is the temperature average for the week before the week in consideration.
    2. temp.2.week is the cumulative temperature average for two weeks before the week in consideration.
    3. temp.3.week is the cumulative temperature average for three weeks before the week in consideration.
    4. temp.4.week is the cumulative temperature average for four weeks before the week in consideration.
    5. temp.5.week is the cumulative temperature average for five weeks before the week in consideration.
    6. temp.6.week is the cumulative temperature average for six weeks before the week in consideration.
  5. Repeat step 4 for precipitation data.
  6. Combine the nest dataset with temperature and precipitation datasets by matching week and years.
  7. Repeat steps 1-6 for all populations.

Results section first graph– number of nests per week

# load data file for Hungary
hungary <- read.csv("../Data/Hungary_numofnests.csv")

# load data file for Galicia
galicia <- read.csv("../Data/Galicia_numofnests.csv")

# load data file for Samouco
samouco <- read.csv("../Data/Samouco_numofnests.csv")

# load data file for Cheetham
cheetham <- read.csv("../Data/Cheetham_numofnests.csv")

# convert year to factor for all population datasets
hungary$week <- as.factor(hungary$week)
galicia$week <- as.factor(galicia$week)
samouco$week <- as.factor(samouco$week)
cheetham$week <- as.factor(cheetham$week)

# plot for Hungary
p1 = ggplot(hungary, aes(x = week, y = num.of.nests)) + xlab("Week of the year") + 
  ylab("Number of nests") + ggtitle("Hungary (n = 180)") + 
  geom_boxplot(fill = "red", alpha = 5/10) + theme_bw() + 
  theme(axis.text.x= element_text(angle = 90))

# plot for Galicia
p2 = ggplot(galicia, aes(x = week, y = num.of.nests)) + xlab("Week of the year") + 
  ylab("Number of nests") + ggtitle("Galicia (n = 489)") + 
  geom_boxplot(fill = "green", alpha = 5/10) + theme_bw() + 
  theme(axis.text.x= element_text(angle = 90))

# plot for Samouco
p3 = ggplot(samouco, aes(x = week, y = num.of.nests)) + xlab("Week of the year") + 
  ylab("Number of nests") + ggtitle("Samouco (n = 663)") + 
  geom_boxplot(fill = "blue", alpha = 5/10) + theme_bw() + 
  theme(axis.text.x= element_text(angle = 90))

# plot for Cheetham
p4 = ggplot(cheetham, aes(x = week, y = num.of.nests)) + xlab("Week of the year") + 
  ylab("Number of nests") + ggtitle("Cheetham (n = 473)") + 
  geom_boxplot(fill = "yellow", alpha = 5/10) + theme_bw() + 
  theme(axis.text.x= element_text(angle = 90))

# arrange the plots together
grid.arrange(p1, p2, p3, p4, nrow = 2, ncol = 2)

Discussion plot for Hungary

# add extra space to right margin of plot within frame
par(mar=c(5, 4, 4, 6) + 0.1)

# plot moving averages for pre-laying period temperature against number of week
plot(nests.per.week$temp.6.week ~ nests.per.week$week, main="",
     ylab="", xlab="", pch = 18, col = "red", xaxt="n", cex.main = 1, axes = FALSE)
# customize y axis
axis(2,col="red", col.axis= "red", las=1)  ## las=1 makes horizontal labels
# add y axis label
mtext("Average temperature (Degree celsius)",side=2,col = "red", line=2.5)
# draw a box around the plot
box()

# Allow a second plot on the same graph
par(new=TRUE)

# Plot the second plot and put axis scale on right
# plot moving averages for pre-laying period precipitation against number of week
plot(nests.per.week$prec.6.week ~ nests.per.week$week, pch=18,  xlab="", ylab="", 
     axes=FALSE, col="blue", cex.main = 1)
# customize y axis
axis(4, col="blue",col.axis="blue",las=1)
# add y axis label
mtext("Average precipitation (mm)",side=4,col="blue",line=2.5) 

# Draw the time axis
axis(1,pretty(range(nests.per.week$week),10))
# add x axis label
mtext("Week of the year",side=1,col="black",line=2.5)